package com.cqc.manage.util.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.cqc.manage.service.Imp.equipmentService.EquMessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Component
// 有个很重要的点 DemoDataListener 不能被spring管理，要每次读取excel都要new,然后里面用到spring可以构造方法传进去
public class EquRecordDataListener extends AnalysisEventListener<EquRecordData> {
    private static final Logger LOGGER = LoggerFactory.getLogger(EquRecordDataListener.class);


    @Autowired
    private EquMessageService equMessageService;


    private static final List<EquRecordData>  equRecordDataList = new ArrayList<>();
    //一行一行读取excel内容
    @Override
    public void invoke(EquRecordData data, AnalysisContext analysisContext) {


        equRecordDataList.add(data);


        System.out.println("****"+data);
    }
    //读取表头内容
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头："+headMap);
    }
    //读取完成之后
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }



    public List<EquRecordData> getEquRecordDataList(){
        return equRecordDataList;
    }


}